package com.store.practice.controller;

import com.store.practice.common.api.CommonResult;
import com.store.practice.model.BgStore;
import com.store.practice.service.StoreManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/storeManage")
@Api(tags = "StoreManageController",description = "门店管理")
public class StoreManageController {
    @Autowired
    private StoreManageService storeManageService;

    @ApiOperation("展示门店列表")
    @GetMapping("/list")
    public CommonResult list(Integer storeId,String name){
        BgStore store = storeManageService.list(storeId, name);
        if (store==null){
            return CommonResult.failed("非门店负责人");
        }
        return CommonResult.success(store);
    }

    @ApiOperation("编辑门店信息")
    @PostMapping("/update")
    public CommonResult update(@RequestBody BgStore store){
        int i = storeManageService.update(store);
        if (i>0){
            return CommonResult.success(i);
        }
        return CommonResult.failed();
    }
}
